@var isAdd = shiro.hasPermission("sys.role.add");
@var isEdit= shiro.hasPermission("sys.role.edit");
@var isDel = shiro.hasPermission("sys.role.delete");
@var isRoleSetting = shiro.hasPermission("sys.role.roleSetting");
@var content = {
<div class="panel panel-success">
    <div class="panel-body">
        <div id="roleTable"></div>
        <script type="text/javascript">
            var table = $('#roleTable').bootstrapTableExtension({
                dataUrl: '/sys/role/list',//数据加载地址
                addUrl: '/sys/role/add',//数据添加地址
                editUrl: '/sys/role/edit',//菜单编辑地址
                delUrl: '/sys/role/delete',//删除数据地址
                isAddBtnIsShow: '${isAdd}' === 'true',
                addBtnText: '添加',
                isEditBtnIsShow: '${isEdit}' === 'true',
                editBtnText: '编辑',
                isDeleteBtnIsShow: '${isDel}' === 'true',
                deleteBtnText: '删除',
                toolbar: 'roleToolbar',
                columns: [
                    {checkbox: true, printIgnore: true},
                    {
                        field: 'name', title: '名称', align: 'center', sortable: true,
                        formatter: function (arg, obj) {
                            if ('${isEdit}' === 'true') {
                                return '<a href="javascript:void(0);" onclick="table.bootstrapTableExtension(\'edit\',\'/sys/role/edit/' + obj.id + '\')">' + arg + '</a>';
                            } else {
                                return arg;
                            }
                        }
                    },
                    {field: 'code', title: '代码', align: 'center', sortable: true},
                    {field: 'represent', title: '描述', align: 'center', sortable: false},
                    {
                        field: 'createTime', title: '创建时间', align: 'center', sortable: true,
                        formatter: function (arg) {
                            return arg.slice(0, 10) + " " + arg.slice(11, 20);
                        }
                    },
                    {
                        field: 'updateTime', title: '修改时间', align: 'center', sortable: true,
                        formatter: function (arg) {
                            return arg.slice(0, 10) + " " + arg.slice(11, 20);
                        }
                    },
                    {
                        field: 'deleteTime', title: '是否已删除', align: 'center', formatter: function (arg) {
                            if (arg == null) {
                                return '否';
                            }
                            return '是，删除时间：' + arg.slice(0, 10) + " " + arg.slice(11, 20);
                        }, visible: false
                    }
                ],
                otherButtons: [
                    {
                        isShow: 'true' === '${isRoleSetting}',
                        classes: 'btn btn-info',
                        iconClasses: 'glyphicon glyphicon-send',
                        text: '权限设置',
                        id: 'btn-setting',
                        btnEvent: function () {
                            var obj = table.bootstrapTable('getSelections');
                            if (obj.length !== 1) {
                                layer.msg('请选择一条数据', {icon: 5});
                                return false;
                            }
                            table.bootstrapTableExtension('newLayer', {
                                url: '/sys/role/roleSetting/' + obj[0].id,
                                title: '权限设置'
                            });
                        }
                    }
                ]
            });
        </script>
    </div>
</div>
@};

@include('../../layout/_open_content.html',{content:content}){}